package com.example.springmvcdemo;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/message")
@RestController
public class MessageController {

    private List<MessageInfo> messageInfoList = new ArrayList<>();

    @RequestMapping(value = "/publish",method = RequestMethod.POST)
    public Boolean publish(@RequestBody MessageInfo messageInfo) {
        messageInfoList.add(messageInfo);
        return true;
    }

    @RequestMapping(value = "/getList")
    public List<MessageInfo> getList() {
        return messageInfoList;
    }

}
